﻿package com.alipay.config;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

public class AlipayConfig {
	
//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

	// 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
	public static String app_id = "2016082600316020";
	
	// 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key ="\n"
      + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQChtDO8GAIl2UML\n"
      + "51l9nl793Hc3EqPDI9gTbyBcV3ftYWVjiWV3rMYAqiQ4Pneqcu3FzNc0Chs1QucE\n"
      + "1nx6PPZ5XZeQry20r1DV+elXn9crAe6s9Sv4CTmZwLGXa8UtUkBQX7VJZ3muiojT\n"
      + "H8NbK4O2YKDM9ZimM6q45fgXpH/RNFprj5hes+DJhBfOGS6bezz61lYR/C0unEq7\n"
      + "tDVpRq9uYHPtn+d4qh6TA1OWh0Lb2FFmxmTjcVwPUqjvOiLr+iUtCXV30W6ZP2rf\n"
      + "zvdyhgNJHB70MkXthQIyGiq/Lznevb3ElQgQZofS74JVHGnSFG7eCHxFokFRBIzl\n"
      + "1iwELl6pAgMBAAECggEBAIilM9at3xrGxu6HOMt7ikAyDpf+a16aqpx5mroNvC1f\n"
      + "0YLUd2czHDsxi9vvhcYGysEMwYqbQ7S1bW1cJuJRI+MZYNwF/LSkNcYsIrBGRVh1\n"
      + "kJCdueMnQIKaIDiZ/Iy45dpFlneKNnx1Wvw16irf0bTLYPbyT2WbYZhP1V99Rfmt\n"
      + "USFdtm+oH0zrFPu2WCS5EgFbV987CdyAX5khsesLDIjekpjGubkM5AZ50QnfiVdH\n"
      + "EZf92lRc0BLnO+8FfjZbPQYFbN7SV3cfrYxRK5FdutFwz5RMN35DdCr0SVH+0j1u\n"
      + "2FwutCO3j/5A8/baypisSOg/iDpLFtWNg4sIuj1bmgECgYEAy5fPAGxaXbGNA58R\n"
      + "Lk03KRiv6vzARx8WZph8HjYIgmZggx9g4eCJfU/W8XFotpFK74sdUd3znpPOCZsp\n"
      + "TE7gMkKVcFuL1eOt5mWBkRQ5brUprzrU3BefhyujAb3tXYzP9xszwjkpbHA1aD2z\n"
      + "uo0+pPFHZquADT0WOizNgLvTBWkCgYEAy1QGAZtLsz8Kzbk5hw+tDBVOUaDw4RpQ\n"
      + "xfWbeFRxJoJd4c3PZ3HjGWLgGHHllDvLl8B0b6a11R04xaqaIX6gqn0qWL/OeQY5\n"
      + "51gkqFC/yDXx8RSN6yTP+E/wOjj2cD1YJVg8Y2GiQiV4MpUcP8atgDPM5uf5ttKu\n"
      + "ssIAFEOvJ0ECgYEAs0jMESNZsIhaFYZOKuf0W0xSHizVZcwKfe5p3nDWrX5aHx3S\n"
      + "wxZn/OIB9jxYae0ogCmReDZsAolGN09b3sbWx2u7DWaQjZoh2XIp1whoSwVd3+F+\n"
      + "8RIceXwD39TQ4kDOIlziB3cu8z8cyN8NFoqrT7Tpm5ALA513pWMu1N6RxYECgYAX\n"
      + "EfWMgR5ZvDFxni6U0IaF9HTqdiRepim8DF4TjSE5iVk1obCCwD1QSBO9Mk8mPpKf\n"
      + "KUsM0BGZmLM0WmMaoc+BCKqhX0ICIV64jRu7rU3VXamR/Q8NOyQNvKQ5NvVfTtaN\n"
      + "hjFz5UQP1UiKFLkb02MkRLxfBrsir0z7I1/27KcXAQKBgEmiXPjZPl5iNyw0g51M\n"
      + "NS72EsWqpUSgFd3U/Mmr1oIf78GGbTbKjbifDR4+h27cw/O/oxSUVIvcBKb+31ce\n"
      + "Re34ATegpUHvz+qoUL5ORBWaT248AhWyIizhLrslbWkYtOZyu+x3Ff2mxXlg9iEt\n"
      + "+zv1Qgw9YOd9Q3iDZOI7Khy/";

	// 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtB+3GHDF8li4ssXV3RzIYWLytr/cGk/td1JXEk1XkbrzFlI4KeBdD67bh/1/0oPCdOrm8aFL2Mfolj5wmeyxnfdQlN0u15nHG+GWDV3+McE64icuDQV97NBu6n6zxw5eljeF3d5gkK3VcJb4dNL0l6w3tvMU21eaS4QsR/3hPLj8Go3/+L3ML5z1ytxDT1Vv92YV+sRZ7k53X7bcZykosPelbOEmta9qqRvh4/HBnjT0udVD6molOkam0cLtXqRbasq+jF04d96Y/ncfxLtNVpq9Y33+ZBbo7+qbHv8m7KFiAm3AAG+cCraKCWYD0L9FcNj68eFVHdRKknoNRfzW6QIDAQAB";

	// 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp";

	// 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String return_url = "http://工程公网访问地址/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp";

	// 签名方式
	public static String sign_type = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	// 支付宝网关
	public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";
	
	// 支付宝网关
	public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /** 
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

